#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
typedef pair<int, int> pii;
int n, m, x, y;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };
const int N = 40;
int a[N][N];
char b[N][N];
int ret = 0;
int cnt = N * N;
void bfs()
{
    queue<pii> as;
    as.push({ x,y });
    memset(a, -1, sizeof(a));
    a[x][y] = 0;
    while (as.size())
    {
        auto e = as.front();
        as.pop();
        int c = e.first;
        int d = e.second;
        for (int k = 0; k < 4; k++)
        {
            int f = c + dx[k];
            int g = d + dy[k];
            if (f >= 1 && f <= n && g >= 1 && g <= m && a[f][g] == -1 && b[f][g] != '*')
            {
                a[f][g] = a[c][d] + 1;
                if (b[f][g] == 'e')
                {
                    ret++;
                    continue;
                }
                as.push({ f,g });
            }
        }
    }
}
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> b[i][j];
            if (b[i][j] == 'k')
            {
                x = i;
                y = j;
            }
        }
    }
    bfs();
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j] != -1 && b[i][j] == 'e')
            {
                cnt = min(cnt, a[i][j]);
            }
        }
    }
    if (ret == 0)
    {
        cout << -1;
    }
    else
        cout << ret << ' ' << cnt;
    return 0;
}